package com.xiweicheng;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@SpringBootApplication
@RestController
public class CloudConfigClientApplication {

	@RequestMapping("/")
	public RespBody home() {
		return RespBody.builder().content("ok...").build();
	}

	@RequestMapping("stores")
	public RespBody stores() {
		return RespBody.builder().content(Arrays.asList(Store.builder().id("1").name("test1").build(),Store.builder().id("2").name("test2").build())).build();
	}

	@RequestMapping("stores/{storeId}")
	public RespBody store(@PathVariable("storeId") Long storeId) {
		return RespBody.builder().content(Store.builder().id(storeId.toString()).name("test" + storeId).build()).build();
	}

	public static void main(String[] args) {
		SpringApplication.run(CloudConfigClientApplication.class, args);
	}
}
